#!/bin/bash

root_dir="datasets/scene_test"

# 遍历所有以 scene-* 开头的目录
for scene_dir in "$root_dir"/scene-*; do
    [ -d "$scene_dir" ] || continue

    scene_name=$(basename "$scene_dir")  # 如 scene-1_image
    prefix=${scene_name%%_image}         # 去掉 _image，得到 scene-1

    image_dir="$scene_dir/images"
    [ -d "$image_dir" ] || continue

    for img_file in "$image_dir"/*.jpg; do
        [ -e "$img_file" ] || continue
        base=$(basename "$img_file")

        # 如果文件已经有 scene-i_ 前缀就跳过
        if [[ "$base" != ${prefix}_* ]]; then
            mv "$img_file" "$image_dir/${prefix}_$base"
        fi
    done
done
